#ifndef clox_compiler_h
#define clox_compiler_h

#include "scanner.h"

typedef struct {
    Token token;
    int scopeDepth;
} Local;

typedef struct {
    Token previous;
    Token current;
    Vector locals;
    int scopeDepth;
} Parser;

typedef enum {
    PRECE_NONE,
    PRECE_ASSIGNMENT,   // =
    PRECE_OR,           // or
    PRECE_AND,          // and
    PRECE_EUALITY,      // == !=
    PRECE_COMPARE,      // > < >= <=
    PRECE_TERM,         // + -
    PRECE_FACTOR,       // * /
    PRECE_UNARY,        // - !
    PRECE_CALL,         // () .
    PRECE_PRIMARY
} Precedence;

typedef void (*ParseFn)(void);

typedef struct {
    ParseFn prefix;
    ParseFn infix;
    Precedence prece;
} ParseRule;

void compile(const char* src);
void parserInit(Parser* parser);

#endif
